﻿using BasicInformation.ApiRead.Application.Command.Supplier;
using BasicInformation.Domain;
using BasicInformation.Dtos;
using BasicInformation.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BasicInformation.ApiRead.Controllers
{
    /// <summary>
    /// 供应商类型控制器——读
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    //[Authorize]
    public class SupplierController : ControllerBase
    {
        private readonly IMediator mediator;

        public SupplierController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 供应商查询分页显示接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiPaging<SupplierDTO>> GetSupplier([FromQuery]GetSupplierCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 供应商类型查询接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaging<SupplierTypeModel>> GetSupplierType([FromQuery]GetSupplierTypeCommand request)
        {
            return mediator.Send(request);
        }

    }
}
